package com.hospital.pharmacy.controller;

import com.hospital.pharmacy.entity.Medicine;
import com.hospital.pharmacy.service.MedicineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping(value = "/pharmacy")
public class MedicineController {
    @Autowired
    MedicineService medicineService;

    @RequestMapping(value = "/submit1",method = RequestMethod.POST)
    public String insertMed(@RequestParam("num")String num,
                            @RequestParam("name")String name,
                            @RequestParam("unit")String unit,
                            @RequestParam("spec")String spec,
                            @RequestParam("type")Integer type,
                            @RequestParam("supplier")Integer supplier,
                            @RequestParam("company")String company,
                            @RequestParam("remark")String remark){

        medicineService.insertMed(num,name,unit,spec,type,supplier,company,remark);
        return "redirect:/html/main.html";
    }
    @RequestMapping(value = "/submit2",method = RequestMethod.POST)
    public String deleteMed(@RequestParam("id")Integer id){
        medicineService.deleteMed(id);
        return "redirect:/html/main.html";
    }
}
